package org.community.detail.service.common.converter;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@Data
@Slf4j
public class DateConverter {

    //格式化字符串转Date类
    public Date formatStringToDate(String dateString,String format) throws ParseException {
        return (new SimpleDateFormat(format)).parse(dateString);
    }

    //Date类型转格式化字符串
    public String dateToFormatString(Date date,String format){
        return (new SimpleDateFormat(format).format(date));
    }
}
